﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using proRFID_DiemDanh.Chung;
using System.Data;
using System.Data.SqlClient;

namespace proRFID_DiemDanh.SinhVien
{
    public class mdSinhVien
    {
        public static DataTable sinhvien_select(string masv)
        {
            mdMain.OpenConnection();
            SqlCommand cmd = new SqlCommand("sp_sinhvien_select", mdMain.cnn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@masv", masv);
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataTable dt = new DataTable();
            da.Fill(dt);
            mdMain.CloseConnection();
            return dt;
        }
        public static DataTable sinhvien_insert(string masv, string hosv, string tensv, string mathe)
        {
            mdMain.OpenConnection();
            SqlCommand cmd = new SqlCommand("sp_sinhvien_insert", mdMain.cnn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@masv", masv);
            cmd.Parameters.AddWithValue("@hosv", hosv);
            cmd.Parameters.AddWithValue("@tensv",tensv);
            cmd.Parameters.AddWithValue("@mathe",mathe);
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataTable dt = new DataTable();
            da.Fill(dt);
            mdMain.CloseConnection();
            return dt;
        }
        public static DataTable sinhvien_update(string masv, string hosv, string tensv, string mathe)
        {
            mdMain.OpenConnection();
            SqlCommand cmd = new SqlCommand("sp_sinhvien_update", mdMain.cnn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@masv", masv);
            cmd.Parameters.AddWithValue("@hosv", hosv);
            cmd.Parameters.AddWithValue("@tensv", tensv);
            cmd.Parameters.AddWithValue("@mathe", mathe);
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataTable dt = new DataTable();
            da.Fill(dt);
            mdMain.CloseConnection();
            return dt;
        }
        public static DataTable sinhvien_delete(string masv)
        {
            mdMain.OpenConnection();
            SqlCommand cmd = new SqlCommand("sp_sinhvien_delete ", mdMain.cnn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@masv", masv);           
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataTable dt = new DataTable();
            da.Fill(dt);
            mdMain.CloseConnection();
            return dt;
        }
    }
}